#!/usr/bin/env python
#coding=utf-8

import time
from codingabc.database import db
from app.models.MyModel import MyModelService

class Role(db.Model, MyModelService):
    __bind_key__ = 'huiwang'
    __tablename__ = 'role'

    role_id = db.Column(db.Integer, primary_key=True)
    role_name = db.Column(db.String(255), default='')
    desc = db.Column(db.String(255), default='')

    def __str__(self):
        return "Role => { \
role_id:%d, role_name:'%s', desc:'%s'}" % (
self.role_id, self.role_name, self.desc)

    __repr__ = __str__


class RoleMenu(db.Model, MyModelService):
    __bind_key__ = 'huiwang'
    __tablename__ = 'role_menu'

    rm_id = db.Column(db.Integer, primary_key=True)
    role_id = db.Column(db.Integer, default=0)
    menu_id = db.Column(db.Integer, default=0)
    menu_type = db.Column(db.Integer, default=0)

    def __str__(self):
        return "RoleMenu => { \
rm_id:%d, role_id:%d, menu_id:%d, menu_type:%d}" % (
self.rm_id, self.role_id, self.menu_id, self.menu_type)

    __repr__ = __str__


class RolePermission(db.Model, MyModelService):
    __bind_key__ = 'huiwang'
    __tablename__ = 'role_permission'

    rp_id = db.Column(db.Integer, primary_key=True)
    role_id = db.Column(db.Integer, default=0)
    p_id = db.Column(db.Integer, default=0)
    add_time = db.Column(db.Integer, default=int(time.time()))
    update_time = db.Column(db.Integer, default=int(time.time()))

    def __str__(self):
        return "RolePermission => { \
rp_id:%d, role_id:%d, p_id:%d, add_time:%d, update_time:%d}" % (
self.rp_id, self.role_id, self.p_id, self.add_time, self.update_time)

    __repr__ = __str__
